package com.tom.architect02.zframework.handler;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Added by Tom on 2024/03/21.
 */
public class MainActivity extends AppCompatActivity {


    Handler threadHandler;
    public void handlerLoop(View view) {
        Thread myThread = new Thread(new Runnable() {
            @Override
            public void run() {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(MainActivity.this, "loop 执行",Toast.LENGTH_SHORT).show();
                    }
                });
                Looper.prepare();
                threadHandler = new Handler() {
                    @Override
                    public void handleMessage(@NonNull Message msg) {
                    }
                };
                Looper.loop(); // 阻塞线程
            }
        });
        myThread.start();
    }
    // threadHandler.sendMessage(threadHandler.obtainMessage());

}
